#!/bin/bash

# Test sheep VDI redundancy level

. ./common

for i in `seq 0 22`; do
	_start_sheep $i;
done

_wait_for_sheep 23

_cluster_format -c 3

for i in `seq 2 4`; do
	$DOG vdi create test$i 20M -c $i -P
done

$DOG vdi create -c 4:2 test5 20M -P
$DOG vdi create -c 4:3 test6 20M -P
$DOG vdi create -c 4:4 test7 20M -P
$DOG vdi create -c 4:5 test8 20M -P
$DOG vdi create -c 16:7 test9 20M -P
$DOG vdi create -c 16:16 fail 20M -P
$DOG vdi snapshot -s tag test2
$DOG vdi clone -s 1 test2 clone

for i in `seq 2 3`; do
	_kill_sheep $i;
done

for i in `seq 23 24`; do
	_start_sheep $i;
done

_wait_for_sheep_recovery 0

$DOG vdi delete clone
$DOG vdi delete -s 1 test2

_vdi_list

for i in `seq 2 9`; do
	$DOG vdi object location test$i -i 1;
done

